import { MergeEditorProps } from '@/components/basicEditor/types'
import {
  FormItemProps,
  InputProps,
  SelectProps,
  UploadProps,
  CheckboxGroupProps,
  CheckboxProps,
  RadioGroupProps,
  RadioProps,
  DatePickerProps,
  TimePickerProps,
  TreeSelectProps,
  TransferProps,
  RateProps,
  SliderProps,
  CascaderProps,
  SwitchProps,
  AutoCompleteProps
} from 'naive-ui'
import { FormItemRuleAsyncValidator, FormItemRuleValidator } from 'naive-ui/es/form/src/interface'

export type UseType = '新增' | '编辑' | '查看'

export type ComponentType =
  | 'NInput'
  | 'NInputPassword'
  | 'NInputSearch'
  | 'NInputTextArea'
  | 'NInputNumber'
  | 'NInputCountDown'
  | 'NSelect'
  | 'NTreeSelect'
  | 'NRadioGroup'
  | 'NCheckbox'
  | 'NCheckboxGroup'
  | 'NAutoComplete'
  | 'NCascader'
  | 'NDatePicker'
  | 'NMonthPicker'
  | 'NRangePicker'
  | 'NWeekPicker'
  | 'NTimePicker'
  | 'NSwitch'
  | 'NStrengthMeter'
  | 'NUpload'
  | 'NIconPicker'
  | 'NRender'
  | 'NSlider'
  | 'NRadio'
  | 'NRate'
  | 'NTransfer'
  | 'NColorPicker'
  | 'Editor'

export type RadioType = 'NRadio' | 'NRadioButton'

export interface LabelValue {
  label: string
  value: string | number
}

export type MergeUploadProps = UploadProps & { size?: number } // 上传文件大小，单位M

export type TransferFunc = (value: any) => any

export interface BasicFormItemPros {
  label: string // 表单项名称
  key: string // 表单项绑定属性名
  component: ComponentType // 表单项组件类型
  hidden?: boolean // 是否展示该项，默认不隐藏， 可用与一些有上下层级关系的选项
  span?: number // 表单项占据栅栏列数, 默认一行24格
  originProps?: FormItemProps // 表单项原生属性, 可覆盖默认属性
  componentProps?:  // 表单项组件原生属性, 可覆盖默认属性
    | InputProps
    | SelectProps
    | UploadProps
    | CheckboxGroupProps
    | RadioGroupProps
    | MergeUploadProps
    | DatePickerProps
    | TimePickerProps
    | TreeSelectProps
    | TransferProps
    | RateProps
    | SliderProps
    | CascaderProps
    | SwitchProps
    | AutoCompleteProps
    | MergeEditorProps
  required?: boolean // 是否必填
  validator?: FormItemRuleValidator | FormItemRuleAsyncValidator // 表单项自定义验证函数

  transferValue?: TransferFunc // 查看模式下, 转义值显示

  // #region 多选单选独有属性
  checkBoxOptions?: Array<LabelValue & CheckboxProps> // 复选框选项以及原生checkBox属性, 可覆盖默认属性
  radioType?: RadioType // 可选择使用radio或者radioButton选项，默认raidio
  radioOptions?: Array<LabelValue & RadioProps> // 单选框选项以及原生radio,或者radioButton属性, 可覆盖默认属性
  // #endregion 多选单选独有属性

  // #region 上传独有属性
  isShowProcess?: boolean // 默认为假，是否显示上传进度
  // #endregion 上传独有属性
}
export type PropsForm = Array<BasicFormItemPros>
